import { fetch } from '../utils/httpRequest'
import { routerRedux } from 'dva/router'
export default {
  namespace: 'login',
  state: {
    isLogin: false
  },
  effects: {
    *login ({ payload }, { select, call, put }) {
      let res = yield call(fetch('/api/AppNews/getNewsList/type/1/p/1'))
      window.sessionStorage.setItem('user', JSON.stringify({
        isLogin: true
      }))
      yield put({type: 'changeLoginState ', payload: {isLogin: true}})
      // 跳转至首页
      yield put(routerRedux.push('/home/list'))
    }
  },
  reducers: {
    changeLoginState (state, {payload}) {
      return {
        ...state,
        ...payload
      }
    }
  }
}